package cn.soulfire.travel.service.impl;

import cn.soulfire.travel.constants.CommentConstant;
import cn.soulfire.travel.domain.Post;
import cn.soulfire.travel.mapper.PostMapper;
import cn.soulfire.travel.service.IPostService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ma.rui.kai
 * @since 2020-10-13
 */
@Service
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements IPostService {
   @Autowired
   private PostMapper postMapper;
    @Override
    public void disable(Post post) {
        if (post.getState().equals(CommentConstant.COMMENT_ENABLE)){
            post.setState(CommentConstant.COMMENT_DISABLE);
            postMapper.updateById(post);
        }else {
            if (post.getState().equals(CommentConstant.COMMENT_DISABLE)){
                post.setState(CommentConstant.COMMENT_ENABLE);
                postMapper.updateById(post);
            }
        }
    }
}
